package com.burgeon.backend.SHOPBACKEND.service.Impl;

import com.burgeon.backend.SHOPBACKEND.rest.rfm.QuerryRFMData;
import com.burgeon.backend.SHOPBACKEND.service.BackendRFMService;
import com.burgeon.backend.entity.Info;
import com.burgeon.backend.mappers.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class BackendRFMServiceImpl implements BackendRFMService {
    @Autowired
    private AccountMapper accountMapper;

    /**
     *
     * @param account
     * @param type  最近消费 7  消费频次 3 消费金额 8
     * @return
     */
    @Override
    public HashMap getData(String account,String type) {
        Info info = GetInfo(account);
        QuerryRFMData querryRFMData = new QuerryRFMData(info.getUrl(), info.getAccount(), info.getPassword());
        try {
            return querryRFMData.getData(type);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }

    private Info GetInfo(String token) {
        return accountMapper.GetAccData(token);
    }
}
